package driver

import (
	"context"

	"task/ecode"
	pb "task/pb/business"

	log "github.com/sirupsen/logrus"
)

// CallBusiness call business.
func CallBusiness(ctx context.Context, resourceId int64) (int64, error) {
	var err error
	req := &pb.BusinessRequest{
		ResourceId: resourceId,
	}
	resp := new(pb.BusinessResponse)
	if resp, err = BusinessClient.Business(ctx, req); err != nil {
		log.Errorf("Business rpc error(%v)", err)
		return -1, ecode.RPCError
	}
	log.Infof("Business rpc result(%+v)", resp.Result)
	return resp.Result, nil
}
